package it.luigiarpino.sudoku;

import java.awt.*;
import javax.swing.*;

public class GuiScegliDifficolta extends JDialog {
    
    
    
	private static final long serialVersionUID = 1L;
    
    
    public GuiScegliDifficolta(java.awt.Frame parent, boolean modal) {
        
        
        super(parent, modal);
        // imposta il Look&Feel di sistema 
        try 
        { 
            javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName()); 
        } 
        catch(Exception e) {}
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Select level");
        JPanel jPanel=new JPanel(new FlowLayout(FlowLayout.CENTER));
        
        JButton jButtonEasy=new JButton("Easy");
        jButtonEasy.setActionCommand("2");
        jButtonEasy.addActionListener(new java.awt.event.ActionListener() 
        {
            public void actionPerformed(java.awt.event.ActionEvent evt) 
            {
                jButtonActionPerformed(evt);
            }
        });
        
        JButton jButtonMedium=new JButton("Medium");
        jButtonMedium.setActionCommand("3");
        jButtonMedium.addActionListener(new java.awt.event.ActionListener() 
        {
            public void actionPerformed(java.awt.event.ActionEvent evt) 
            {
                jButtonActionPerformed(evt);
            }
        });
        
        JButton jButtonHard=new JButton("Hard");
        jButtonHard.setActionCommand("4");
        jButtonHard.addActionListener(new java.awt.event.ActionListener() 
        {
            public void actionPerformed(java.awt.event.ActionEvent evt) 
            {
                jButtonActionPerformed(evt);
            }
        });
        
        jPanel.add(jButtonEasy);
        jPanel.add(jButtonMedium);
        jPanel.add(jButtonHard);
        this.getContentPane().add(jPanel);
        this.pack();
        this.setResizable(false);
    }
    

   

    private void jButtonActionPerformed(java.awt.event.ActionEvent evt) 
    {
    	int difficolta=Integer.valueOf( ((JButton)evt.getSource()).getActionCommand() ).intValue();
    	this.setVisible(false);
        GuiSchema schema=new GuiSchema(new javax.swing.JFrame(), true, difficolta);
        schema.setLocationRelativeTo(null);
        schema.setVisible(true);
        if(schema.vittoria){
            javax.swing.JOptionPane.showMessageDialog(null,"Hai Vinto","Complimenti",javax.swing.JOptionPane.INFORMATION_MESSAGE);
        }
        dispose();
    }
    

    public static void main(String args[])
    {
    	GuiScegliDifficolta gui = new GuiScegliDifficolta(new javax.swing.JFrame(), true);
        gui.setLocationRelativeTo(null);
        gui.setVisible(true);
    }
    

    
}

